﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;

namespace Ajaxna.Designers
{
    public class TextEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            UI.SimpleTextEditorForm frm = new UI.SimpleTextEditorForm();
            frm.TextValue = value as string;
            
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                return frm.TextValue;

            return value;
        }

        public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
        {
            return false;
        }
    }
}
